package com.eight.teacher.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.EduTeacher;
import com.eight.common.vo.Result;
import com.eight.teacher.service.TeacherService;
import com.eight.teacher.vo.EduTeacherVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: qy8-education
 * @description: TeacherController
 * @author: 韩宗耀
 * @create: 2023-05-27 15:12
 **/
@RestController
@RequestMapping("/teacher/teacher")
@Api(tags = "讲师")
public class TeacherController {
    @Resource
    private TeacherService teacherService;

    @PostMapping("/findTeacher/{pageCurrent}/{pageSize}")
    @ApiOperation(value = "查询所有讲师/分页/模糊")
    public Result findTeacher(
            @PathVariable Integer pageCurrent,
            @PathVariable Integer pageSize,
            @RequestBody EduTeacherVo eduTeacherVo
    ){
        Page<EduTeacher> teacher = teacherService.findTeacher(pageCurrent, pageSize, eduTeacherVo);
        return new Result(200,"查询成功",teacher);
    }

    @PostMapping("/updateTeacher")
    @ApiOperation(value = "修改讲师信息")
    public Result updateTeacher(@RequestBody EduTeacher eduTeacher){
        Integer updateTeacher = teacherService.updateTeacher(eduTeacher);
        return new Result(200,"修改成功",updateTeacher);
    }

    @PostMapping("/changeStatus")
    @ApiOperation(value = "修改讲师状态")
    public Result changeStatus(@RequestBody EduTeacher eduTeacherVo){
        Integer changeStatus = teacherService.changeStatus(eduTeacherVo);
        return new Result(200,"更改成功",changeStatus);
    }
}
